<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="sch">
        <span id="aa"></span>
    </div>
</body>
<script>
    var schedule = 30;
    function calculateTime(){
        if (schedule > 1) {
            schedule = schedule - 1;
            document.getElementById("aa").innerHTML = schedule;
            console.log(schedule);
        }else{
            clearInterval();
            console.log("倒计时结束");
            schedule = 30;
        }
    }

    var timer = setInterval("calculateTime()", 1000);
</script>

</html>